package com.example.seh.util;

import android.app.Activity;
import android.util.Log;
import android.view.View;

import com.example.seh.constant.Constant;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class JudgeContent {

    public static void setData(String content, final DataCallback callback) {
        OkHttpClient okHttpClient = new OkHttpClient();

        Request request = new Request.Builder()
                .get()
                .url(Constant.SENSITIVE_WORD + content )
                .build();

        Call call = okHttpClient.newCall(request);
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                callback.onFailure();
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String squareData = response.body().string();
                callback.onResponse(squareData);
            }
        });
    }

    public interface DataCallback {
        void onFailure();

        void onResponse(String data);
    }
}
